import java.io.*;
import java.net.*;
import java.util.*;
import java.security.Security;
import java.security.Provider;
import javax.net.ssl.*;
import java.text.DecimalFormat;

public class CurrentIndexData {    

    private static boolean debug = false;
    private static boolean save = false;
    private String myUrl = null;
    private String urlReturnString = new String();
    private Vector urlReturnVector= new Vector(10);

    public static void main (String[] args) {

	CurrentIndexData  myd = new CurrentIndexData ();
	
	myd.setUrl("http://www.mrci.com/qpnight.asp");
	myd.connectToUrl();
	myd.formatUrlReturnString(myd.getUrlReturnString());

    }

    public void setUrl (String url) {
	myUrl = url;
    }

    public void connectToUrl () {

	String url_return_string = "";
	Vector colum_data_v = new Vector ();

	URL url ;

	HttpsURLConnection httpsConnection = null;

	try {            
	    url = new URL (myUrl);

	    try {              

		StringBuffer buff1= new StringBuffer("");  
		if (myUrl.startsWith("https:")) {
		    httpsConnection = (HttpsURLConnection)url.openConnection();                
		    httpsConnection.setDoOutput(false);                
		    httpsConnection.connect();                

		    if (debug) {
			System.out.println("Connection Code and Message:" + 
					   httpsConnection.getResponseCode() + 
					   " - " + httpsConnection.getResponseMessage()+"\n");
		    }

		    BufferedReader in = new BufferedReader(new InputStreamReader
			(httpsConnection.getInputStream()));

		    url_return_string = in.readLine();

		    while (url_return_string != null) {
			buff1.append(url_return_string);
			url_return_string = in.readLine();
		    }

		    in.close();            
		}
		else if (myUrl.startsWith("http:")) {   

		    HttpURLConnection httpConnection = null;
		    httpConnection = (HttpURLConnection)url.openConnection();                
		    httpConnection.setDoOutput(false);                
		    httpConnection.connect();                

		    if (debug) {
			System.out.println("Connection Code and Message:" + 
					   httpConnection.getResponseCode() + 
					   " - " + httpConnection.getResponseMessage()+"\n");
		    }

		    BufferedReader in = new BufferedReader(new InputStreamReader
			(httpConnection.getInputStream()));

		    url_return_string = in.readLine();
	   
		    while (url_return_string != null) {
			buff1.append(url_return_string);
			url_return_string = in.readLine();
		    }

		    in.close();            
		}
	       
		url_return_string = buff1.toString();
		
		urlReturnString = url_return_string;
		
	    } catch (IOException ioe) {                
		System.out.println(ioe.getMessage());  
		System.exit(1);            
	    }        
	} catch (MalformedURLException mue) {            
	     System.out.println(mue.getMessage());            
	    System.exit(1);        
	} catch (Exception e) {            
	    e.printStackTrace();            
	    System.exit(1);        
	}    
    }

    public String getUrlReturnString () {
	return urlReturnString;
    }

    public String formatUrlReturnString (String url_r_str) {
	String temp_str = url_r_str;
	
	temp_str = temp_str.replaceAll(">", ">\n");
	temp_str = temp_str.replaceAll("</", "\n<");
	temp_str = temp_str.trim();
	System.out.println(temp_str);
	return temp_str;
    }

    public Vector stringToVector (String input) {

	Vector url_return_vector = new Vector ();
	String element = null;
	StringTokenizer tokens = new StringTokenizer(input, ",");
	while (tokens.hasMoreTokens()) {
	    element = tokens.nextToken();
	    if (element != null) {
		url_return_vector.addElement(element);
	    }
	}

	return url_return_vector;
    }
}








